package com.xxx.util;

import org.solar.util.ThreadLocalUtil;
import org.solar.web.CorsAllowFilter;

import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import javax.servlet.http.HttpServletRequest;
import java.io.IOException;
@WebFilter(filterName = "sessionFilter",urlPatterns = {"/*"})
public class BaseFilter extends CorsAllowFilter {

    @Override
    public void init(FilterConfig filterConfig){

    }

    @Override
    public void doFilter(ServletRequest req, ServletResponse res, FilterChain filterChain) throws IOException, ServletException {
        ThreadLocalUtil.put("request",req);
        ThreadLocalUtil.put("Host",((HttpServletRequest)req).getHeader("Host"));
        super.doFilter(req,res,filterChain);
        ThreadLocalUtil.remove();
    }

    @Override
    public void destroy() {

    }
}
